Skip to content

chore(security): Actions permissions and test/script alerts (CodeQL) - #188

Merged
Madraka merged 2 commits into
mainfrom
chore/codeql-backlog-2
Nov 10, 2026
Merged

Madraka merged 2 commits into
mainfrom
chore/codeql-backlog-2

Conversation

@Madraka

@Madraka Madraka commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

The second half of the CodeQL backlog on main (the first is #187, production code). Touches different files from #187; no published package changes, so no changeset.

Actions permissions (alerts 1, 2, 3, 4)

ci.yml (jobs ts, rust, contract-drift) and npm-smoke.yml (smoke) ran with the default token. Both now set a top-level permissions: contents: read. Checked every step:

Step Needs
actions/checkout contents: read
actions/setup-node cache: pnpm, Swatinem/rust-cache, taiki-e/cache-cargo-install-action the Actions cache service (its own runtime token), not GITHUB_TOKEN
pnpm/action-setup, dtolnay/rust-toolchain nothing (public downloads)
lint, typecheck, tests, build:packages, smoke:pack, git diff --exit-code nothing

Nothing comments on PRs, uploads artifacts or releases, or writes checks, so no job is widened.

Tests and scripts

Alert File Fix
39 scripts/release-plan.ts:40 name.replaceAll("/", "%2F")
38 scripts/mcp-tools-doc.ts:37 backslashes escaped before pipes in table cells; --check still passes (README unchanged)
37 scripts/i18n-codemod/catalog-entries.ts:58 stringBodyAsJson: one pass over a literal's body (either quote), \' → ', bare " escaped, other escapes kept. The replace chain turned 'a\"b' into invalid JSON. New apps/studio/test/catalog-entries.test.ts
40 astro-renderer/test/corrections.test.ts:74 the "no markup" assertion is case-insensitive (/…/i)
8 analytics/test/helpers/fake-wae.ts:139 weightsBesideLiteralZero, a linear scan; fake-wae-check.test.ts checks it against the old regex (cases + 20k seeded random queries) and on 10k quantileWeighted( / 50k if(

Alert 45 (core-ts/src/testing-automations.ts:200, "unescaped '.' before 'example.com/nope'") is fixed in #187, not here. The SARIF's related location shows the sink: surfaces/body.ts built new RegExp(...) for each code fence's closer from the body's line text, and CodeQL followed this test's markdown into it. #187 replaces that with a closesFence scanner, so the string is no longer used as a regex anywhere. Escaping the dot in the fixture would have changed the test's link and left the dynamic RegExp in place.

Checks

pnpm exec vitest run for analytics (13 files / 375 tests), astro-renderer corrections.test.ts, cli release-plan.test.ts, studio catalog-entries.test.ts and i18n-messages.test.ts; node scripts/mcp-tools-doc.ts --check; pnpm size:check; pnpm design:lint; Biome on the changed files.

Alert map (all 25)

Alert Result
1, 2, 3, 4 fixed here
8, 37, 38, 39, 40 fixed here
11, 12, 13, 16, 17, 19, 20, 23, 24, 30, 32, 35, 36, 41, 42, 43, 44, 45 fixed in #187

Nothing is dismissed.

🤖 Generated with Claude Code

Close CodeQL alerts 1-4, 8, 37, 38, 39 and 40 on main.

- ci.yml and npm-smoke.yml get a top-level `permissions: contents:
  read`. No step needs more: checkout reads, and setup-node, rust-cache
  and cache-cargo-install use the Actions cache service, not the token;
  nothing comments, uploads or writes checks.
- release-plan.ts encodes every "/" of a package name (replaceAll).
- mcp-tools-doc.ts escapes backslashes before pipes in table cells
  (the generated README is unchanged).
- The i18n codemod decodes string literals of either quote in one pass,
  so an escaped backslash before a quote is never taken apart.
- The fake WAE's type-error check is a linear scan (equivalence fuzz
  and an adversarial case), and the corrections test's tag filter is
  case-insensitive.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Madraka <[email protected]>
- Move the codemod's string-literal test from apps/studio (its tsconfig
  rootDir is apps/, so importing scripts/ failed typecheck with TS6059)
  to packages/cli/test, where the other scripts' tests live.
- weightsBesideLiteralZero probes each comma once, however many `if(`
  share it, and scans the `doubleN,` argument by hand instead of a
  sticky regex: it was still quadratic on one comma followed by a long
  whitespace run (CodeQL alert 51 on the PR). The linearity test now
  covers that input.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Madraka <[email protected]>
@Madraka
Madraka merged commit 02c4bc8 into main Nov 10, 2026
8 checks passed
@Madraka
Madraka deleted the chore/codeql-backlog-2 branch November 10, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants